﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Kiiro.Common.Interfaces;

namespace Kiiro.Common.Entities
{
    [Serializable]
    public class Comment : BaseEntity, IEntity
    {
        #region Private Properties

        private string text;
        private List<ValidationMessage> textMessage = new List<ValidationMessage>();
        private int discussionId;
        private List<ValidationMessage> discussionIdMessage = new List<ValidationMessage>();

        #endregion

        #region Public Properties

        public string Text
        {
            get { return text; }
            set
            {
                if (text != value)
                {
                    text = value;
                    UpdateEntity();
                }
            }
        }

        public List<ValidationMessage> TextMessage
        {
            get { return textMessage; }
            set
            {
                if (textMessage != value)
                {
                    textMessage = value;
                    UpdateEntity();
                }
            }
        }

        public int DiscussionId
        {
            get { return discussionId; }
            set
            {
                if (discussionId != value)
                {
                    discussionId = value;
                    UpdateEntity();
                }
            }
        }

        public List<ValidationMessage> DiscussionIdMessage
        {
            get { return discussionIdMessage; }
            set
            {
                if (discussionIdMessage != value)
                {
                    discussionIdMessage = value;
                    UpdateEntity();
                }
            }
        }


        #endregion

        #region IEntity Members


        public new bool IsValid()
        {
            return AllValidationErrors().Count == 0;
        }

        public new List<ValidationMessage> AllValidationErrors()
        {
            List<ValidationMessage> allErrors = new List<ValidationMessage>();

            allErrors.AddRange( TextMessage );
            allErrors.AddRange(DiscussionIdMessage);

            return allErrors;
        }

        public new void ClearValidationMessages()
        {
            TextMessage.Clear();
            DiscussionIdMessage.Clear();
        }

        #endregion
    }
}

/*************************************************************************
 * 
 * $Log: /Internal Projects/Kiiro/Kiiro.Common/Entities/Comment.cs $
 * 
 * 3     17/08/09 10:38a Camerons
 * Added check-in comments section
 * 
 ************************************************************************/